package com.lxq.action;

import com.lxq.model.Role;
import com.lxq.model.RoleParams;
import com.lxq.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;

import java.util.ArrayList;
import java.util.List;

@Controller

public class RoleController {
    @RequestMapping("/rolesa")
    public ModelAndView requestBody(@RequestBody RoleParams roleParams){
        System.out.println(roleParams.getRoleName());
        System.out.println(roleParams.getPageParams().getStart());


        List<Role> rl=new ArrayList<Role>();
        Role role=new Role();
        role.setRolename("iron man");
        Role ro=new Role();
        ro.setRolename("caption");

        ModelAndView mv=new ModelAndView();
        mv.setView(new MappingJackson2JsonView());
        mv.addObject(rl);

        return mv;
    }

    @RequestMapping("/delelist")
    public  ModelAndView delerole(@RequestBody List<Integer> rollist){
        ModelAndView mv=new ModelAndView();
        mv.setView(new MappingJackson2JsonView());
        System.out.println(rollist);
        return mv;
    }
    @RequestMapping("/rlist")
    public  ModelAndView roleList(@RequestBody List<RoleParams> roleList){
        System.out.println("begin");
        ModelAndView mv=new ModelAndView();
        mv.setView(new MappingJackson2JsonView());
        for (RoleParams role : roleList) {
            System.out.println(role.getRoleName());
        }
        return  mv;
    }
@RequestMapping("/xulie")
    public  ModelAndView xul(User user){
    System.out.println(user);
        ModelAndView mv=new ModelAndView();
        mv.setView(new MappingJackson2JsonView());
        mv.addObject(user);
        return mv;
}
}
